﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Aplikacja_PostgreSQL
{
    class Query
    {
        private String query;

        public Query(string query)
        {
            this.query = query;
        }
        public int QueryAnalyze()
        {
            char[] charsToTrim = { ',', '.', ' ', ':', ';' };
            query = query.TrimEnd(charsToTrim);
            query = query.TrimStart(charsToTrim);
            query = query.ToLower();

            if (query.StartsWith("select"))
                return 1;
            else if (query.StartsWith("insert"))
                return 2;
            else if (query.StartsWith("update"))
                return 3;
            else if (query.StartsWith("delete"))
                return 4;
            else
                return 0;
        }
        public override string ToString()
        {
            return query;
        }
        public void SetQuery(string query)
        {
            this.query = query;
        }
        public string GetQuery()
        {
            return query;
        }
    }
}
